package com.shycloud.mido.organ.test.algorithms;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Xiaoxing Yu
 * @date 2020/8/8
 **/
public class PermutationAnswer {

	public void main(String[] args) {
		List<List<Integer>> resList = new ArrayList<>();

		int[] nums = new int[]{1, 2, 3,};

		List<Integer> curList = new ArrayList<>();
		doSearch(resList, curList, nums);

 	}

	private void doSearch(List<List<Integer>> resList, List<Integer> curList, int[] nums) {
		if (curList.size() == nums.length) {
			resList.add(new ArrayList<>(curList));
			return;
		}

		for (int i = 0; i < nums.length; i++) {
			if (curList.contains(nums[i])) continue;
			curList.add(nums[i]);
			doSearch(resList, curList, nums);
			curList.remove(curList.size() - 1);
		}
	}

}
